package com.yfp.system.controller;

import com.yfp.common.core.domain.R;
import com.yfp.common.core.web.controller.BaseController;
import com.yfp.common.core.web.page.TableDataInfo;
import com.yfp.system.domain.SysUserCompany;
import com.yfp.system.domain.SysUserCompanyDTO;
import com.yfp.system.service.SysUserCompanyService;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;


/**
 * (SysUserCompany)表控制层
 *
 *
 * @since 2024-01-15 17:52:42
 */
@RestController
@RequestMapping("sysUserCompany")
@Tag(name = "xxx")
public class SysUserCompanyController extends BaseController {
    /**
     * 服务对象
     */
    @Resource
    private SysUserCompanyService sysUserCompanyService;

    /**
     * 分页查询
     *
     * @param sysUserCompany 筛选条件
     * @return 查询结果
     */
    @GetMapping
    @Operation(summary ="分页查询")
    public TableDataInfo queryByPage(SysUserCompany sysUserCompany) {
        startPage();
        return getDataTable(this.sysUserCompanyService.queryByPage(sysUserCompany));
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("{id}")
    @Operation(summary ="通过主键查询单条数据")
    public R<SysUserCompany> queryById(@PathVariable("id")String  id) {
        return R.ok(this.sysUserCompanyService.queryById(id));
    }

    /**
     * 新增数据
     *
     * @param sysUserCompany 实体
     * @return 新增结果
     */
    @PostMapping
    @Operation(summary ="新增数据")
    public R<SysUserCompany> add(@RequestBody SysUserCompanyDTO sysUserCompany) {
        return R.ok(this.sysUserCompanyService.insert(sysUserCompany));
    }

    /**
     * 编辑数据
     *
     * @param sysUserCompany 实体
     * @return 编辑结果
     */
    @PutMapping
    @Operation(summary ="编辑数据")
    public R<SysUserCompany> edit(SysUserCompanyDTO sysUserCompany) {
        return R.ok(this.sysUserCompanyService.update(sysUserCompany));
    }
}
